#include"process.h"
#include<stdio.h>
#include<unistd.h>

//函数指针
typedef void (*callback_t)(double total , double current); //定义一个函数指针类型callback_t

double total = 1024.0;
double speed = 1.0;

//回调函数
void DownLoad(callback_t cb)
{
    double current = 0;
    while(current<=total)
    {
        cb(total,current);
        //下载代码
        usleep(3000);  //充当下载数据
        current += speed;
    }
    printf("\ndownload %.2lfMB Done\n",current);
}

void UpLoad(callback_t cb)
{
    double current = 0;
    while(current<=total)
    {
        cb(total,current);
        //下载代码
        usleep(3000);  //充当下载数据
        current += speed;
    }
    printf("\nuownload %.2lfMB Done\n",current);
}

int main()
{
    DownLoad(FlushProcess);
    DownLoad(FlushProcess);
    UpLoad(FlushProcess);
    return 0;
}
